import React from 'react';
import {
  MyProcess as MyProcessIns,
  workflowJumpConfigRegister
} from '@/components/workflow';
interface State {
  myProcessRef: any;
}
class MyProcess extends React.Component<any, State> {
  componentDidMount() {
    workflowJumpConfigRegister([
      {
        procDefKey: 'LEAVE',
        jumpFunc: () => {
          return '/dashboard';
        }
      },
      {
        procDefKey: 'SAL_SO_RETURN',
        jumpFunc: async (e, c) => {
          if (e.procInstName.includes('RJ')) {
            //即场退货
            return ['NOTSUBMIT', 'REJECTED', 'INTERRUPT'].includes(e.status)
              ? `/order/salesReturnManage/JC/edit/edit/${e.businessKey}`
              : `/order/salesReturnManage/JC/view/${e.businessKey}`;
          } else {
            //客舱退货
            return ['NOTSUBMIT', 'REJECTED', 'INTERRUPT'].includes(e.status)
              ? `/order/salesReturnManage/KC/edit/edit/${e.businessKey}`
              : `/order/salesReturnManage/KC/view/${e.businessKey}`;
          }
        }
      },
      {
        procDefKey: 'SAL_SO_TRADE',
        jumpFunc: async (e, c) => {
          //即场退货
          return ['NOTSUBMIT', 'REJECTED', 'INTERRUPT'].includes(e.status)
            ? `/order/saleOrderManage/orderQuery/tradeOrder/edit/${e.businessKey}`
            : `/order/saleOrderManage/orderQuery/tradeOrder/view/${e.businessKey}`;
        }
      }
    ]);
  }
  render() {
    return <MyProcessIns push={this.props.push} />;
  }
}
export default MyProcess;
